//Page Object

//0 用来引入发送请求的request方法
import { request } from "../../request/index.js"
Page({
  data: {
    // 轮播图数组
    swiperList: [],
    // 导航数组
    catesList: [],
    // 楼层数据
    floorList: []
  },
  //options(Object)
  onLoad: function (options) {
    this.getSwiperList()
    this.getCateList()
    this.getFloorList()
  },
  // 1.获取轮播图数据(自己封装的promise)
  async getSwiperList() {
    const result = await request({
      url: "/home/swiperdata"
    })

    this.setData({
      swiperList: result // 将轮播图数据存到data中
    })
  },
  // 2.获取分类导航数据
  async getCateList() {
    const result = await request({
      url: "/home/catitems"
    })
    this.setData({
      catesList: result
    })
  },
  // 3.获取楼层数据
  async getFloorList() {
    const result = await request({
      url: "/home/floordata"
    })
    this.setData({
      floorList: result
    })
  }
})
